{extend name="../../../view/public/base" /}

{block name="body"}
<div class="bw-container">
    <div class="bw-main">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">

                <!--搜索区域-->
                <div class="layui-card">
                    <div class="layui-collapse" lay-accordion="" lay-filter="search">
                        <div class="layui-colla-item">
                            <h2 class="layui-colla-title">查询条件</h2>
                            <div class="layui-colla-content">
                                <form id="searchForm" class="layui-form" lay-filter="searchForm" autocomplete="off">

                                    <div class="layui-form-item layui-inline">
                                        <label class="layui-form-label">序号</label>
                                        <div class="layui-input-inline">
                                            <input type="number" name="id" placeholder="请输入序号"
                                                   class="layui-input">
                                        </div>
                                    </div>

                                    <div class="layui-form-item layui-inline">
                                        <label class="layui-form-label">明细类型：</label>
                                        <div class="layui-input-inline">
                                            <select name="type" id="type"  >
                                                <option value="">请选择</option>
                                                {volist name="getTypeList" id="vo" key="k"}
                                                <option value="{$key}" >{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="searchBtn">
                                                搜索
                                            </button>
                                            <button class="layui-btn layui-btn-primary" type="button" onclick="resetForm()">
                                                重置
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>

                <!--列表区域-->
                <div class="layui-card" style="background-color: #F2F2F2;">
                    <table id="list" lay-filter="listFilter"></table>

                    <!--工具栏-->
                    <script type="text/html" id="listToolbar">
                        <a class="layui-btn layui-btn-sm layui-bg-black" lay-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh" style="font-size: 8px !important;"></i> </a>
                    </script>

                    <!--租户ID-->
                    <script type="text/html" id="member_id">
                        {{ d.member_id }}
                    </script>
                    <!--类型:admin=系统,recharge=充值.miniapp=购买应用,cloud_packet=购买云市场套餐-->
                    <script type="text/html" id="type_text">
                        <span style="color: #1E9FFF;"> {{ d.type_text }}</span>
                    </script>
                    <!--变更-->
                    <script type="text/html" id="value">
                        {{ d.value }}
                    </script>
                    <!--变更前-->
                    <script type="text/html" id="before">
                        {{ d.before }}
                    </script>
                    <!--变更后-->
                    <script type="text/html" id="after">
                        {{ d.after }}
                    </script>
                    <!--备注-->
                    <script type="text/html" id="memo">
                        {{ d.memo }}
                    </script>
                    <!--创建时间-->
                    <script type="text/html" id="create_time">
                        {{ formatDate(d.create_time) }}
                    </script>
                    <!--更新时间-->
                    <script type="text/html" id="update_time">
                        {{ formatDate(d.update_time) }}
                    </script>
                    <!--昵称-->
                    <script type="text/html" id="Member_nickname">
                        {{ d.Member.nickname }}
                    </script>

                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>
    var element, layer, form, table, bwajax, $;

    layui.use(['element', 'layer', 'form', 'table', 'bwajax'], function () {
        element = layui.element;
        layer = layui.layer;
        form = layui.form;
        table = layui.table;
        bwajax = layui.bwajax.instance();
        $ = layui.jquery;

        //执行列表
        table.render({
            elem: '#list',
            url: "{:Url('/manage/member/walletBill/index')}",
            response: {
                statusCode: 200,  //规定成功的状态码，默认：0
            },
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.data.total, //解析数据长度
                    "data": res.data.data.list //解析数据列表
                };
            },
            toolbar: '#listToolbar',
            cols: [[
                {type:'checkbox', fixed: 'left'},
                {field: 'id', title: '序号', align: 'center', minWidth: 50, fixed: 'left'},
                // {field: 'member_id', title: '租户ID', align: 'center', minWidth: 80, templet: '#member_id'},
                // {field: 'Member_nickname', title: '昵称', align: 'center', minWidth: 150, templet: '#Member_nickname'},
                {field: 'type', title: '类型', align: 'center', minWidth: 100, templet: '#type_text'},
                {field: 'value', title: '变更', align: 'center', minWidth: 120, templet: '#value'},
                {field: 'before', title: '变更前', align: 'center', minWidth: 120, templet: '#before'},
                {field: 'after', title: '变更后', align: 'center', minWidth: 120, templet: '#after'},
                {field: 'memo', title: '备注', align: 'center', minWidth: 200, templet: '#memo'},
                {field: 'create_time', title: '创建时间', align: 'center', minWidth: 200, templet: '#create_time'},
                {field: 'update_time', title: '更新时间', align: 'center', minWidth: 200, templet: '#update_time'},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });

        //监听表格头部工具栏事件
        table.on('toolbar(listFilter)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'refresh':
                    reload();
                    break;
                case 'add':
                    bwOpenIframe("{:Url('/manage/member/walletBill/add')}", '新增');
                    break;
                case 'del':
                    var checkStatus = table.checkStatus('list');
                    var data = checkStatus.data;

                    var idsArr = [];
                    data.forEach(function(value) {
                        idsArr.push(value.id);
                    });
                    ids = idsArr.join(',');

                    if(!ids) layer.msg('没有选中行', {icon: 2});
                    else del(ids);

                    break;
            }
        });

        //监听工具条
        table.on('tool(listFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）

            switch (layEvent) {
                case 'edit':
                    bwOpenIframe("{:Url('/manage/member/walletBill/edit')}?id=" + data.id, '编辑');
                    break;
                case 'del':
                    del(obj.data.id);
                    break;

            }
        });

        form.on('submit(searchBtn)', function (data) {
            reload(1);

            return false;
        })


    });
</script>
{/block}